#define  _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<limits.h>
int myAtoi(char* s)
{
    int flag = 1;
    int count = 0;
    int f = 0;
    int len = strlen(s);
    while (*s == ' ')
    {
        count++;
        s++;
    }
    if (*s == '-')
    {
        flag = -1;
        count++;
        s++;
        f++;
    }
    if (*s == '+')
    {
        s++;
        count++;
        f++;
    }
    while (*s == '0')
    {
        count++;
        s++;
    }
    if (*s > '9' || *s < '0' || f == 2)
        return 0;
    long sum = (long)(*s - 48);
    s++;
    count++;
    while (*s <= '9' && *s >= '0' && count < len)
    {
        sum = sum * 10 + (long)(*s - 48);
        if (sum * flag >= INT_MAX)
            return INT_MAX;
        if (sum * flag <= INT_MIN)
            return INT_MIN;
        s++;
    }
    return sum * flag;
}
int main()
{
    int a = myAtoi("-2443");
    printf("%d\n", a);
    return 0;
}